package com.lxw.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    public static final String EXCHANGE_TOPIC = "exchange_topic";
    public static final String QUEUE_EMAIL = "queue_email";
    public static final String ROUTING_EMAIL = "routing.#.email.#";
    public static final String QUEUE_SMS = "queue_sms";
    public static final String ROUTING_SMS = "routing.#.sms.#";

    @Bean(EXCHANGE_TOPIC)
    public Exchange getExchange(){
        return ExchangeBuilder.topicExchange(EXCHANGE_TOPIC).durable(true).build();
    }

//    @Bean(EXCHANGE_TOPICS_INFORM)
//    public Exchange EXCHANGE_TOPICS_INFORM(){
//        //  .durable(true)交换机持久化，消息队列重启后交换机仍然存在
//        return ExchangeBuilder.topicExchange(EXCHANGE_TOPICS_INFORM).durable(true).build();
//    }
//    @Bean(QUEUE_INFORM_SMS)
//    public Queue QUEUE_INFORM_SMS(){
//        return new Queue(QUEUE_INFORM_SMS);
//    }
//    @Bean(QUEUE_INFORM_EMAIL)
//    public Queue QUEUE_INFORM_EMAIL(){
//        return new Queue(QUEUE_INFORM_EMAIL);
//    }
//
//    @Bean()
//    public Binding BINDING_QUEUE_INFORM_SMS(@Qualifier(QUEUE_INFORM_SMS) Queue queue,
//                                       @Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange){
//        return BindingBuilder.bind(queue).to(exchange).with("inform.#.sms.#").noargs();
//    }
//    @Bean()
//    public Binding BINDING_QUEUE_INFORM_EMAIL(@Qualifier(QUEUE_INFORM_EMAIL) Queue queue,
//                                            @Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange){
//        return BindingBuilder.bind(queue).to(exchange).with("inform.#.email.#").noargs();
//    }



}
